home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
archiver
/
mdcd10.zip
/
MDCD1213.ASM
< prev
next >
Wrap
Assembly Source File
|
1988-10-26
|
61KB
|
1,221 lines
;---- 10/26/1988 00:26:45 ----}
name mdcd1213
page 82,132
title 'MDCD1213.OBJ 12/13 bit LZW file compress/decompress
;-----------------------------------------------------------------------------
; -
; `MDCD1213' -
; -
; This is a modified version of LZ.ARC, obtained from the EXEC PC BBS -
; in Milwaukee WI. on 8/20/88. It has been changed to work as an external -
; modlule and has been tested with Turbo Pascal 5.0. -
; -
; It was assembled with Turbo Assembler 1.0 but will assemble with MASM. -
; but will assemble with MASM. The following modifications have been made: -
; -
; 1. Removed the malloc memory allocation for the hash table out to -
; the caller so that it can be allocated from the heap. -
; 2. Added the CompressFile & DecompressFile function interface. -
; 3. Minor cleanup and use of equ values for easy buffer size changes. -
; 4. Initialized DS variables normally done by MASM/LINK, but not by some -
; other HLL's (e.g. Turbo Pascal). -
; 5. Input file & output file allocated and opened externally by caller. -
; Only the file handles are passed to this module. -
; 6. Super fast CRC 16 (communications type) routine added to accumulate -
; the compressed & decompressed file's CRC for reliability. -
; 7. Original program used a macro file. The few that were used were -
; removed and coded inline for single module simplicity. -
; 8. Increased disk input and output buffers to 8192 bytes each -
; (from 1024). This seems to be a good trade-off for speed/memory. -
; 9. Moved the disk input and output buffers to CS to preserve precious -
; Turbo Pascal DS space. -
; 10. Combined LZCOMP.ASM & LZDCMP.ASM into 1 module -
; 11. Allowed the beginning file offset to write to and read from to be -
; specified to provide for (n) files in a compressed file. -
; 12. Replaced DIVide instructions with shifts, ands and moves. -
; 13. Added 13 bit LZW compression based on passed parameter. -
; -
; Modified by.. -
; Mike Davenport -
; Mike Davenport & Associates -
; 6751 N. Blackstone Ave. Suite 252 -
; Fresno CA 93710 -
; Voice: (209) 298-8846 -
; CIS: 76676,1362 -
; PLINK: MIKE D -
; GENIE: MDAVENPORT -
; Amiga Techniques + PC Tech BBS - (GT POWER) -
; (209) 298-8453 - 1200-9600 HST (24 hours) -
; -
; Original Author.. -
; Tom Pfau -
; Digital Equipment Corporation -
; Parsippany, NJ -
; -
;-----------------------------------------------------------------------------
; -
; --------------------- -
; MODULE CHANGE HISTORY -
; --------------------- -
; -
; change# ..date.. by .................. change ........................ -
; -
; 000 09-06-88 md Original module creation -
; 001 10-19-88 md added 13 bit LZW compression -
; 001 10-26-88 md Original module finished -
; -
;-----------------------------------------------------------------------------
;----------
; constants
;----------
clear equ 256 ;Clear code
eof equ 257 ;End of file marker
fhdr_len equ 128 ;size of file header for file type 1
first_free equ 258 ;First free code
;NOTE: this module will not handle buffers larger than 8k due to the design
; of the original code. It carries the total bits in the buffer waiting
; to be written to disk in a word then divides by 8 to compare bytes.
; Buffers > 8192 will cause the WORD that holds the total bits to
; overflow. I decided not to mess with this because buffers > 4096
; didn't seem to have a worthwhile memory vs. speed tradeoff that
; justified the non-trivial changes. In other words, I'm lazy!
input_data_size equ 8192 ;input data buffer size
input_data_chk equ 8187 ;size to check end of input coming up
output_data_size equ 8192 ;output data buffer size
output_data_chk equ 8188 ;size to check output buffer write
;--------------------------
; compress hash table entry
;--------------------------
hash_rec struc
first dw ? ; First entry with this value
next dw ? ; Next entry along chain
char db ? ; Suffix char
hash_rec ends
;----------------------------
; decompress hash table entry
;----------------------------
dhash_rec struc
dnext dw ? ; prefix code
dchar db ? ; suffix char
dhash_rec ends
;------------------------------ DATA SEGMENT ---------------------------------
data segment word
; data will be initialized upon entry into CompressFile or DecompressFile
; because some HLL's do not do this as does MASM/LINK.
; original LZCOMP.ASM data
bit_offset dw ? ;
free_code dw ? ;
hash_seg dw ? ;segment of hash table from caller
input_handle dw ? ;input file handle from caller
input_offset dw 0 ;offset of next byte to read for input
input_size dw 0 ;number of input bytes read
k db ? ;
max_code dw ? ;
nbits dw ? ;number of bits for current code size
output_handle dw ? ;output file handle from caller
prefix_code dw ? ;
; original data unique to LZDCMP.ASM
dhash_seg dw ?
cur_code dw ?
old_code dw ?
in_code dw ?
stack_count dw 0
dmax_code dw 512 ;hash table bytes for 9 bit codes
fin_char db ?
masks dw 1ffh,3ffh,7ffh,0fffh,0ffffh ;9-13 bit masks
dbit_offset